<?php
namespace App\Pay\Gateway\Wechat;

use App\Pay\Config\Config;

abstract class Gateway
{

    /**
     * @var array
     */
    protected $result;

    abstract protected function getTradeType(): string;

    protected function requestOrder($payload)
    {
        $payload['sign'] = Request::sign($payload);
        $this->result = Request::api('pay/unifiedorder', $payload);
        return $this;
    }

    /**
     * @param $name
     * @return mixed|string
     */
    public function get($name)
    {
        return empty($this->result[$name]) ? '' : $this->result[$name];
    }

    public function result()
    {
        return $this->result;
    }
}
